package cn.xuexiyuan.ribbonconsumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class ConsumerController {

    @Autowired
    RestTemplate restTemplate;

    @GetMapping(value = "/ribbon-consumer")
    public String helloConsumer(){
        // 访问地址时服务名 test-service ,而不是一个具体的地址
        return restTemplate.getForEntity("http://test-service/hello", String.class).getBody();
    }
}
